#ifndef _ODN_RGBA_H
#define _ODN_RGBA_H

namespace ouden
{
	namespace utility
	{
		
		typedef float scalar_t;
		
		class RGBAColor
		{
		
		public:
		
		    scalar_t r;
		    scalar_t g;
		    scalar_t b;
		    scalar_t a;
		
		    RGBAColor(scalar_t R = 0, scalar_t G = 0, scalar_t B = 0, scalar_t A = 0) : r(R), g(G), b(B), a(A) {}
		    RGBAColor(const RGBAColor &color) : r(color.r), g(color.g), b(color.b), a(color.a) {}
		
		     //assignment
		     const RGBAColor &operator=(const RGBAColor &color)
		     {
		          r = color.r;
		          g = color.g;
		          b = color.b;
		          a = color.a;
		
		          return *this;
		     }
		
		     //equality
		     const bool operator==(const RGBAColor &color) const
		     {
		          return ((r == color.r) && (g == color.g) && (b == color.b) && (a == color.a));
		     }
		
		     //inequality
		     const bool operator!=(const RGBAColor &color) const
		     {
		          return !(*this == color);
		     }
		
		     //add
		     const RGBAColor operator+(const RGBAColor &color) const
		     {
		          return RGBAColor(r + color.r, g + color.g, b + color.b, a + color.a);
		     }
		
		     //add (opposite of negation)
		     const RGBAColor operator+() const
		     {    
		          return RGBAColor(*this);
		     }
		
		
		     //subtraction
		     const RGBAColor operator-(const RGBAColor& color) const
		     {    
		          return RGBAColor(r - color.r, g - color.g, b - color.b, a - color.a);
		     }
		     
		     //self-multiply
		     const RGBAColor &operator*=(const scalar_t &s)
		     {
		          r *= s;
		          g *= s;
		          b *= s;
		          a *= s;
		          
		          return *this;
		     }
		
		     // scalar self-divecide
		     const RGBAColor &operator/=(const scalar_t &s)
		     {
		          const float recip = 1/s; // for speed, one divecision
		
		          r *= recip;
		          g *= recip;
		          b *= recip;
		          a *= recip;
		
		          return *this;
		     }
		
		     // post multiply by scalar
		     const RGBAColor operator*(const scalar_t &s) const
		     {
		          return RGBAColor(r*s, g*s, b*s, a*s);
		     }
		
		     // pre multiply by scalar
		     friend inline const RGBAColor operator*(const scalar_t &s, const RGBAColor &color)
		     {
		          return color*s;
		     }
		
		     // divecide by scalar
		     const RGBAColor operator/(scalar_t s) const
		     {
		          s = 1/s;
		
		          return RGBAColor(s*r, s*g, s*b, s*a);
		     }
		
		};

	} //namespace utility
} //namespace ouden

#endif //_ODN_RGBA_H
